<?php
// +----------------------------------------------------------------------
// | NewThink [ Think More,Think Better! ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2018 http://www.newthink.cc All rights reserved.
// +----------------------------------------------------------------------
// | 版权所有：山西创泰网络科技有限公司
// +----------------------------------------------------------------------
// | Author: 燕南天 QQ:81020302 Date:2018-08-01 Time:18:59
// +----------------------------------------------------------------------

namespace app\api\controller;

use app\base\model\AdminHash;

class Demo extends Base
{
    
    public function index(){
        echo "课程演示页面";
    }
    public function RedisModelHash(){
        
        $model = new AdminHash();
        $data= [
            'name'=>'Mikkle\' RedisHash',
            "hash_edit"=>'要修改的字段',
        ];
        echo "添加的数据".PHP_EOL;
        dump($data);
        $model->save($data);
        $id  = $model->id;
        echo "添加Id为 $id ".PHP_EOL;
        echo "添加后查询Hash数据为".PHP_EOL;
        dump($model->RedisHash->setKey($id )->get());
        $model->data(['hash_edit'=>'这个字段修改了',])->isUpdate(true,['id'=>$id ])->save();
        echo "修改后查询Hash数据为".PHP_EOL;
        dump($model->RedisHash->setKey($id )->get());
        echo "添加后Hash库所有 key列表".PHP_EOL;
        dump($model->RedisHash->keys("*"));
        $model->destroy($id );
        echo "删除后Hash库所有 key列表".PHP_EOL;
        dump($model->RedisHash->keys("*"));
    }
    
}